#ifndef COLOR_HPP
#define COLOR_HPP
#include "Math.hpp"
class Color
{
public:
   Color() : r(0), g(0), b(0), a(0) {}

   Color(float aR, float aG, float aB, float aA=1.0f)
      : r(aR), g(aG), b(aB), a(aA) {}

   float operator[](int i) const {return *(&r + i); }
   float& operator[](int i) {return *(&r + i); }

   bool operator==(const Color& aRHS) const
   {
      return r == aRHS.r && g == aRHS.g && b == aRHS.b && a == aRHS.a;
   }
   Color operator*(float f) const { return Color(r*f, g*f, b*f,a*f); }
   Color operator/(float f) const { return Color(r/f, g/f, b/f,a/f); }
   Color operator+(const Color& f) const { return Color(r+f.r, g+f.g, b+f.b, a+f.a); }
   Color operator-(const Color& f) const { return Color(r-f.r, g-f.g, b-f.b, a-f.a); }
   bool operator<(const Color& f) const
   {
      if (r < f.r) return true;
      if (r > f.r) return false;
      if (g < f.g) return true;
      if (g > f.g) return false;
      if (b < f.b) return true;
      if (b > f.b) return false;
      if (a < f.a) return true;
      return false;
   }
   void clamp()
   {
      Math::clamp(r, 0, 1);
      Math::clamp(g, 0, 1);
      Math::clamp(b, 0, 1);
      Math::clamp(a, 0, 1);
   }
   void Apply() const;
   static const Color cBLACK;
   static const Color cWHITE;
   float r,g,b,a;
};

inline Color interpolate(float t, const Color& a, const Color& b)
{
   return b * t + a * (1 - t);
}

#include <vector>

class TriColor
{
public:
   TriColor(Color oneColor) : a(oneColor), b(oneColor), c(oneColor) {}
   TriColor() {}
   TriColor(Color aa, Color bb, Color cc) : a(aa), b(bb), c(cc) {}
   Color a;
   Color b;
   Color c;
};

class TriColorList : public std::vector<TriColor>
{
};
typedef std::vector<Color> ColorList;

#endif